package dosgi.core.util;

import org.osgi.framework.BundleContext;
import org.osgi.service.log.LogService;
import org.osgi.util.tracker.ServiceTracker;

@SuppressWarnings( { "rawtypes" , "unchecked" } )
public class LogHelper {

	private static ServiceTracker logServiceTracker;
	private static LogService logService;
	
	public static LogService getLogger() {
		return logService;
	}

	public static void initialize(BundleContext bundleContext) {
		logServiceTracker = new ServiceTracker(bundleContext, LogService.class.getName(), null);
        logServiceTracker.open();
        logService = (LogService) logServiceTracker.getService();
	}
	
	public static void close() {
		logServiceTracker.close();
	}
}
